package com.example.demo.Interceptor;


import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import java.io.IOException;
import java.nio.charset.StandardCharsets;

@Component
public class TokenInterceptor implements HandlerInterceptor {

    @Autowired
    private RedisTemplate redisTemplate;


    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        return true;
        /*try {
            String token = request.getHeader("authorization");
            if(token == null|| redisTemplate.opsForValue().get("token:"+token.substring(7))==null ){
                response.sendError(444,"请先登录");
                return false;
            }
            return true;
        } catch (Exception e) {
            response.sendError(777,"服务器内部错误！");
            return false;
        }*/
    }
}
